<?php
	function CrearComboBoxFormularioCliente($tipo, $selected_id)
	{
		require_once("../include/conec.php");
		$link = Conectarse();
		
		
		if($tipo == 'RENTACODEUDOR'){
			echo "<select class='formulario' id='RENTACODEUDOR' onchange='seleccionarOpcionFormularioCliente(this.id, this.options[this.selectedIndex].value)'>";
			$tipo = "RENTA";
		}
		else
		{
			if($tipo == 'REGION')
				echo "<select class='formulario' id='".$tipo."' onchange='seleccionarOpcionFormularioCliente(this.id, this.options[this.selectedIndex].value); CrearComboBoxComunaAjax(this.options[this.selectedIndex].value, 1);'>";
			else
				echo "<select class='formulario' id='".$tipo."' onchange='seleccionarOpcionFormularioCliente(this.id, this.options[this.selectedIndex].value)'>";
		}
		$result = mysql_query("SELECT id_parametro,valor FROM parametros WHERE tipo LIKE '$tipo' AND estado = 1 ORDER BY id", $link);
		while($row=mysql_fetch_array($result))
		{
			//echo "<option value='".$row['id_parametro']."'";
			echo "<option value='".$row['id_parametro']."'";
			if($selected_id == $row['id_parametro'])
				echo " selected";
			echo ">".$row['valor']."</option>";	
		}
		echo "</select>";
		
	}
	
	function FormularioMostrarClientes($rut, $nombre, $apellido)
	{
		require_once("../include/conec.php");
		$link = Conectarse();
		$result = mysql_query("SELECT * FROM clientes WHERE rut LIKE '%$rut%' AND nombres LIKE '%$nombre%' AND ape_paterno LIKE '%$apellido%'", $link);
		?>
	
		
			<h4>Resultado Busqueda - Clientes</h4>
			<table class='tabla_grilla'>
				<tr class='encabezado_tabla_grilla'>
					<th>RUT</th>
					<th>Nombres</th>
					<th>Apellidos</th>
					<th>Telefonos</th>
					<th>Email</th>
					<th>Accion</th>		
				</tr>
		<?php 
				while($row=mysql_fetch_array($result)){
				echo "<tr onclick='location.href=\"form_mantenedor_cliente.php?id_cliente=".$row['id']."\"'";
				echo " title='Modificar Cliente'>";
				echo "<td>".formatea_rut($row['rut'])."</td>";
				echo "<td>".$row['nombres']."</td>";
				echo "<td>".$row['ape_paterno']." ".$row['ape_materno']."</td>";
				echo "<td>";
				echo "<img src='../img/telefono.gif'> ";
				echo $row['tel_particular']."</td>";
				echo "<td>".$row['email']."</td>";
				echo "<td align='center'>Editar</td>";
				echo "</tr>";
				}
				mysql_free_result($result);
			echo "</table>";
		
	}
	
	?>